#define _CRT_SECURE_NO_WARNINGS   1

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main() 
{
	int n;
	cin >> n;
	int be, en;
	vector<pair<int, int>> data;
	while (n--) 
	{
		cin >> be >> en;
		data.push_back(make_pair(be,en));
	}

	sort(data.begin(), data.end(), [](pair<int, int>& a, pair<int, int>& b) 
	{
		return a.second < b.second;
	});

	int count = 1;
	int pre = data[0].second;
	for (size_t i = 1; i < data.size(); i++) 
	{
		if (pre <= data[i].first) 
		{
			count++;
			pre = data[i].second;
		}
	}
	cout << count << endl;
	return 0;
}

